import pandas as pd
import matplotlib.pyplot as plt
# 读取CSV文件
data = pd.read_csv('data_resource\environmental_data.csv')
# 转换时间列为日期时间格式
data['timestamp'] = pd.to_datetime(data['timestamp'])
# 绘制海洋温度随时间的变化曲线
plt.figure(figsize=(10, 6))
plt.plot(data['timestamp'], data['temperature'], color='blue', label='Ocean temperature')
plt.xlabel('time')
plt.ylabel('temperature')
plt.title('Ocean temperature change')
plt.xticks(rotation=45) 
plt.legend()
plt.grid(True)
plt.show()
# 绘制风速随时间的变化曲线
plt.figure(figsize=(10, 6))
plt.plot(data['timestamp'], data['wind_speed'], color='green', label='Wind speed')
# plt.scatter(data['timestamp'], data['wind_speed'], color='green', label='Wind speed')
plt.xlabel('time')
plt.ylabel('Wind speed')
plt.title('Wind speed change')
plt.xticks(rotation=45)
plt.legend()
plt.grid(True)
plt.show()